/*
	Voxel terrain simulation
*/

#include "voxel_1.cl"

enum {
	COUNT_3D	= _VOX_COUNT_3D,
	BORDER_SIZE	= _BORDER_SIZE,
};


Voxel Simulate (Voxel voxels[COUNT_3D])
{
	return voxels[ XYZ_TO_I( 0, 0, 0 ) ];
}


kernel void Main (read_only image2d_t inputImage, write_only image2d_t outputImage, int iteration, int4 blockCoord)
{
	const int3	coord3d		= GetGlobalCoord();
	const int2	out_coord	= GetTexCoord( coord3d );
	const int3	global_coord = blockCoord.xyz + coord3d;

	Voxel	in_voxels[ COUNT_3D ];
	ReadVoxels9( inputImage, coord3d, in_voxels );

	Voxel v = Simulate( in_voxels );
	WriteVoxel( outputImage, out_coord, v );
}
